<template>
  <div id="app">
    <nav class="navbar">
      <div class="nav-content">
        <h1>养老院管理系统</h1>
        <div class="nav-subtitle">关爱长者 · 温馨服务</div>
      </div>
    </nav>
    
    <div class="container">
      <div class="sidebar">
        <div class="menu-title">功能菜单</div>
        <button 
          @click="currentView = 'resident-list'"
          :class="{ active: currentView === 'resident-list' }">
          <i class="fas fa-users"></i>
          老人列表
        </button>
        <button 
          @click="currentView = 'add-resident'"
          :class="{ active: currentView === 'add-resident' }">
          <i class="fas fa-user-plus"></i>
          添加老人
        </button>
      </div>
      
      <div class="main-content">
        <div class="content-card">
          <ResidentList v-if="currentView === 'resident-list'" 
            @edit-resident="editResident"
            @view-health="viewHealth" />
          <AddResident v-if="currentView === 'add-resident'" />
          <EditResident v-if="currentView === 'edit-resident'"
            :resident="selectedResident"
            @update-complete="currentView = 'resident-list'" />
          <HealthRecords v-if="currentView === 'health-records'"
            :residentId="selectedResident?._id" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import ResidentList from './components/ResidentList.vue'
import AddResident from './components/AddResident.vue'
import EditResident from './components/EditResident.vue'
import HealthRecords from './components/HealthRecords.vue'

export default {
  name: 'App',
  components: {
    ResidentList,
    AddResident,
    EditResident,
    HealthRecords
  },
  data() {
    return {
      currentView: 'resident-list',
      selectedResident: null
    }
  },
  methods: {
    editResident(resident) {
      this.selectedResident = resident
      this.currentView = 'edit-resident'
    },
    viewHealth(resident) {
      this.selectedResident = resident
      this.currentView = 'health-records'
    }
  }
}
</script>

<style>
/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Microsoft YaHei', sans-serif;
  background-color: #f0f2f5;
  color: #333;
}

/* 导航栏样式 */
.navbar {
  background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
  color: white;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.5rem;
}

.nav-content h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.nav-subtitle {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* 主容器样式 */
.container {
  display: flex;
  max-width: 1200px;
  margin: 20px auto;
  gap: 20px;
  padding: 0 20px;
}

/* 侧边栏样式 */
.sidebar {
  width: 220px;
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.menu-title {
  font-size: 1rem;
  color: #666;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #eee;
}

.sidebar button {
  display: flex;
  align-items: center;
  width: 100%;
  margin-bottom: 10px;
  padding: 12px 15px;
  background-color: transparent;
  color: #666;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sidebar button i {
  margin-right: 10px;
  font-size: 1.1rem;
}

.sidebar button:hover {
  background-color: #f5f7fa;
  color: #1e88e5;
}

.sidebar button.active {
  background-color: #e3f2fd;
  color: #1e88e5;
}

/* 主内容区域样式 */
.main-content {
  flex: 1;
}

.content-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  padding: 25px;
}

/* 通用按钮样式 */
button {
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.3s ease;
}

button:hover {
  transform: translateY(-1px);
}

/* 表单样式 */
input, select, textarea {
  transition: border-color 0.3s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: #1e88e5;
  outline: none;
}
</style>
